﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 面向对象_字段与属性
{
    //class Student
    //{
    //    //Student类的字段name
    //    private string name = "carma";
    //    private int id = 0;

    //    //name对应的属性
    //    public string Name
    //    {
    //        //set
    //        //value就是调用set方法的时候传入的字符串参数
    //        set { name = value; }
    //        //get
    //        get{ return name; }

    //    }

    //    public int ID
    //    {
    //        set { id = value; }

    //        get { return id; }
    //    }

    //}
    class Student
    {
        //情况1：用于对数据进行校验
        private int score = 0;


        public int Score 
        { 
            get { return score; }

            set 
            { 
                //传入的分数必须在0到100之间
                if (value < 0 || value > 100)
                {
                    Console.WriteLine("学生分数必须在0到100之间！");
                    return;
                }

                score = value;
            }
        }
    }

    //情况2：对数据的输入输出格式进行设置
    class Clock
    {
        public double seconds = 0.0;

        //Hours获取小时数据以及设置小时数据
        public double Hours
        {
            get { return seconds / 3600 ; }
            set { seconds = value * 3600 ; }
        }

        //Minutes获取分钟数据以及设置分钟数据
        public double Minutes
        {
            get { return seconds / 60 ; }
            set { seconds = value * 60 ; }
        }
    }


    class Player
    {
        public int Money
        {
            get;
            set;
        }
    }
    internal class Program
    {
        static void Main(string[] args)
        {
            Player player = new Player();
            player.Money = 100;
            Console.WriteLine(player.Money);










            //Clock clock = new Clock();
            //clock.Minutes = 20;
            //Console.WriteLine(clock.Minutes);
            //Console.WriteLine(clock.Hours);












            //Student student = new Student();

            //student.Score = 110;
            //Console.WriteLine(student.Score);

            Console.Read();
        }
    }
}
